package org.example.aaaatest.a1;

import com.amap.car.order.i18n.util.TimeZoneUtil;

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.TimeZone;

/**
 * @description:
 * @author: wangbaogui
 * @create: 2025/4/9 19:43
 **/
public class s2 {
    public static long convertTimestampToNewTimezone(long timestamp, ZoneId targetZoneId) {
        // 将时间戳转换为 Instant
        Instant instant = Instant.ofEpochMilli(timestamp);

        // 将 Instant 转换为目标时区的 ZonedDateTime
        ZonedDateTime zonedDateTime = instant.atZone(targetZoneId);

        // 返回转换后的毫秒值
        return zonedDateTime.toInstant().toEpochMilli();
    }

    public static void main(String[] args) {
        long originalTimestamp = System.currentTimeMillis(); // 当前时间戳

//        ZoneId targetZoneId = ZoneId.of("Asia/Japan"); // 目标时区是东九区
        TimeZone timeZone = TimeZoneUtil.getAdminTimeZone(35.713246,139.762315);
        ZoneId zoneId = timeZone.toZoneId();
        System.out.println("zoneId = " + zoneId);

        long newTimestamp = convertTimestampToNewTimezone(originalTimestamp, zoneId);
        System.out.println("原始时间戳: " + originalTimestamp);
        System.out.println("newTimestamp = " + newTimestamp);
    }
}
